package com.senlan.water.common.excel;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.metadata.data.WriteCellData;
import com.senlan.water.common.constant.AppealTypeEnum;
import org.springframework.stereotype.Component;

/**
 * 客诉诉求导出，appealType字段转换器
 */
@Component
public class CustomerAppealTypeExcelConvert implements Converter<String> {


    @Override
    public WriteCellData<?> convertToExcelData(WriteConverterContext<String> context) throws Exception {
        if (context.getValue() != null) {
            if (String.valueOf(AppealTypeEnum.APPEAL_TYPE_COMPLAIN.getCode()).equals(context.getValue())){
                return new WriteCellData<>(AppealTypeEnum.APPEAL_TYPE_COMPLAIN.getMessage());
            }else if (String.valueOf(AppealTypeEnum.APPEAL_TYPE_SUGGEST.getCode()).equals(context.getValue())){
                return new WriteCellData<>(AppealTypeEnum.APPEAL_TYPE_SUGGEST.getMessage());
            }
        }
        return Converter.super.convertToExcelData(context);
    }
}
